package cn.ekgc.bmdsad.day11;

import java.io.*;

public class Text6 {
    public static void main(String[] args) {
        try (ObjectOutputStream out = new ObjectOutputStream ( new FileOutputStream ( "d:/a/obj.txt" ) )) {
        Student stu = new Student ( "张三", 17);
        out.writeObject ( stu );

        } catch (FileNotFoundException e) {
            e.printStackTrace ();
        } catch (IOException e) {
            e.printStackTrace ();
        }


    }
}
class Student implements Serializable {
    String name;

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    int age;
}
